# written by Rainer Poisel (rainer.poisel@fh-stpoelten.ac.at)

STEGIT_COMMON=common
STEGIT_ENGINES=embedding protocols
STEGIT_FACTORIES=factory
STEGIT_IO=io
PULSEAUDIO_MODULE=pa-module

WHICH_BUILD=debug


ifeq ($(DEBUG_BUILD),no)
WHICH_BUILD=all
endif

default: debug

release: 
	$(MAKE) DEBUG_BUILD=no all

debug:
	$(MAKE) DEBUG_BUILD=yes all

stegit-common:
	for dir in $(STEGIT_COMMON); do $(MAKE) -C $$dir $(WHICH_BUILD); done

stegit-engines: stegit-common
	for dir in $(STEGIT_ENGINES); do $(MAKE) -C $$dir $(WHICH_BUILD); done

stegit-factories: stegit-common stegit-engines
	for dir in $(STEGIT_FACTORIES); do $(MAKE) -C $$dir $(WHICH_BUILD); done

stegit-io: stegit-common stegit-engines stegit-factories
	for dir in $(STEGIT_IO); do $(MAKE) -C $$dir PULSE_SUPPORT=yes $(WHICH_BUILD); done

stegit: stegit-engines stegit-factories stegit-io

all: 
	$(MAKE) DEBUG_BUILD=yes stegit

.PHONY: clean all stegit

clean: 
	@for dir in $(STEGIT_COMMON); do (cd $$dir; $(MAKE) clean); done
	@for dir in $(STEGIT_ENGINES); do (cd $$dir; $(MAKE) clean); done
	@for dir in $(STEGIT_FACTORIES); do (cd $$dir; $(MAKE) clean); done
	@for dir in $(STEGIT_IO); do (cd $$dir; $(MAKE) clean); done
	@for dir in $(PULSEAUDIO_MODULE); do (cd $$dir; $(MAKE) clean); done

help:
	@echo "Options can be added to the make command."
	@echo "   example: make ALSA_SUPPORT=yes PULSE_SUPPORT=yes"
	@echo ""
	@echo "StegIT-2 compilation options:"
	@echo "   ALSA_SUPPORT=yes"
	@echo "      add ALSA sound support"
	@echo "   PULSE_SUPPORT=yes"
	@echo "      add pulse audio sound support"
	@echo ""
	@echo "Following makefiles use custom options:"
	@echo "   development/trunk/Makefile"
	@echo "      ALSA_SUPPORT"
	@echo "      PULSE_SUPPORT"
	@echo ""

